import request from 'utils/request'
/*
  获取所有的频道
*/
export const getChannels = () => {
  return request.get('/channels')
}

/*
  data: {}
  获取所有的频道
*/
export const getArticleList = data => {
  return request.get('/mp/articles', {
    params: data
  })
}

/**
 * 删除文章
 * @param {*} id
 * @returns
 */
export const delArticle = (id) => {
  return request({
    url: `/mp/articles/${id}`,
    method: 'delete',
  })
}

/**
 * 发送请求添加文章
 * @param {*} data
 * @returns
 */
export const addArticle = ({draft = false, ...data}) => {
  return request({
    url: `/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  })
}

/**
 * 根据id获取文章详情
 * @param {*} id
 * @returns
 */
export const getArticle = (id) => {
  return request({
    url: `/mp/articles/${id}`,
    method: 'get',
  })
}

/**
 * 发送请求修改文章
 * @param {*} data
 * @returns
 */
export const editArticle = ({draft=false, ...data}) => {
  return request({
    url: `/mp/articles/${data.id}?draft=${draft}`,
    method: 'put',
    data,
  })
}





